home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / demos / Using Images, Bitmaps, and Metafiles / Improving Performance by Avoiding Automatic Scaling / GDITEST40.dpr
Encoding:
Text File  |  2003-10-15  |  2.3 KB  |  92 lines

  1. program GDITEST40;
  2.  
  3. uses
  4.   Classes,
  5.   Windows,
  6.   Messages,
  7.   SysUtils,
  8.   GDIPAPI,
  9.   GDIPOBJ;
  10.  
  11. Procedure OnPaint(DC: HDC);
  12. var
  13.   graphics : TGPGraphics;
  14.   Image: TGPImage;
  15. begin
  16.   graphics := TGPGraphics.Create(DC);
  17.   Image:= TGPImage.Create('..\..\Media\FRUIT.JPG');
  18.  
  19.   graphics.DrawImage(image, 10, 10);
  20.   graphics.DrawImage(image, 230, 10, image.GetWidth, image.GetHeight);
  21.  
  22.   Image.Free;
  23.   graphics.Free;
  24. end;
  25.  
  26.  
  27. function WndProc(Wnd : HWND; message : UINT; wParam : Integer; lParam: Integer) : Integer; stdcall;
  28. var
  29.   Handle: HDC;
  30.   ps: PAINTSTRUCT;
  31. begin
  32.   case message of
  33.     WM_PAINT:
  34.       begin
  35.         Handle := BeginPaint(Wnd, ps);
  36.         OnPaint(Handle);
  37.         EndPaint(Wnd, ps);
  38.         result := 0;
  39.       end;
  40.  
  41.     WM_DESTROY:
  42.       begin
  43.         PostQuitMessage(0);
  44.         result := 0;
  45.       end;
  46.  
  47.    else
  48.       result := DefWindowProc(Wnd, message, wParam, lParam);
  49.    end;
  50. end;
  51.  
  52. var
  53.   hWnd     : THandle;
  54.   Msg      : TMsg;
  55.   wndClass : TWndClass;
  56. begin
  57.    wndClass.style          := CS_HREDRAW or CS_VREDRAW;
  58.    wndClass.lpfnWndProc    := @WndProc;
  59.    wndClass.cbClsExtra     := 0;
  60.    wndClass.cbWndExtra     := 0;
  61.    wndClass.hInstance      := hInstance;
  62.    wndClass.hIcon          := LoadIcon(0, IDI_APPLICATION);
  63.    wndClass.hCursor        := LoadCursor(0, IDC_ARROW);
  64.    wndClass.hbrBackground  := HBRUSH(GetStockObject(WHITE_BRUSH));
  65.    wndClass.lpszMenuName   := nil;
  66.    wndClass.lpszClassName  := 'GettingStarted';
  67.  
  68.    RegisterClass(wndClass);
  69.  
  70.    hWnd := CreateWindow(
  71.       'GettingStarted',       // window class name
  72.       'Improving Performance by Avoiding Automatic Scaling',       // window caption
  73.       WS_OVERLAPPEDWINDOW,    // window style
  74.       Integer(CW_USEDEFAULT), // initial x position
  75.       Integer(CW_USEDEFAULT), // initial y position
  76.       Integer(CW_USEDEFAULT), // initial x size
  77.       Integer(CW_USEDEFAULT), // initial y size
  78.       0,                      // parent window handle
  79.       0,                      // window menu handle
  80.       hInstance,              // program instance handle
  81.       nil);                   // creation parameters
  82.  
  83.    ShowWindow(hWnd, SW_SHOW);
  84.    UpdateWindow(hWnd);
  85.  
  86.    while(GetMessage(msg, 0, 0, 0)) do
  87.    begin
  88.       TranslateMessage(msg);
  89.       DispatchMessage(msg);
  90.    end;
  91. end.
  92.